package cn.wjdiankong.levideo.dialog;

import com.ss.android.common.applog.GlobalContext;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import cn.wjdiankong.levideo.R;
import cn.wjdiankong.levideo.utils.UIUtil;
import cn.wjdiankong.levideo.view.LevideoDialog;

public class LoginDialog implements OnClickListener{
	
	private View parentView;
	private LevideoDialog dialog;
	
	private View wxLoginView, qqLoginView, wbLoginView;
	
	@SuppressLint("InflateParams")
	public LoginDialog(Activity activity){
		if(parentView == null){
			parentView = LayoutInflater.from(activity).inflate(R.layout.dialog_login, null);
		}
		if(dialog == null){
			dialog = new LevideoDialog(activity, parentView, UIUtil.dip2px(activity, 300), 0);
		}
		wxLoginView = parentView.findViewById(R.id.wechat_login_layout);
		qqLoginView = parentView.findViewById(R.id.qq_login_layout);
		wbLoginView = parentView.findViewById(R.id.wb_login_layout);
		wxLoginView.setOnClickListener(this);
		qqLoginView.setOnClickListener(this);
		wbLoginView.setOnClickListener(this);
	}
	
	public void show(){
		if(dialog != null){
			dialog.show();
		}
	}

	@Override
	public void onClick(View v) {
		switch(v.getId()){
			case R.id.wechat_login_layout:
				UIUtil.showLongHintToast(GlobalContext.getContext(), "小编还在努力争取微信登录授权！");
				if(dialog != null){
					dialog.dismiss();
				}
				break;
			case R.id.qq_login_layout:
				UIUtil.showLongHintToast(GlobalContext.getContext(), "小编还在努力争取QQ登录授权！");
				if(dialog != null){
					dialog.dismiss();
				}
				break;
			case R.id.wb_login_layout:
				UIUtil.showLongHintToast(GlobalContext.getContext(), "小编还在努力争取微博登录授权！");
				if(dialog != null){
					dialog.dismiss();
				}
				break;
		}
	}

}
